package com.imay.live.activity.user.util;

import android.text.InputFilter;
import android.text.Spanned;

import java.util.regex.Matcher;
import java.util.regex.Pattern;

/**
 * Created by Administrator on 2017/7/13 0013.
 */

public class NickFilter implements InputFilter {

    /**
     * Default constructor for LoginFilter doesn't append invalid characters.
     */
    public NickFilter() {
        super();
    }

    @Override
    public CharSequence filter(CharSequence source, int start, int end, Spanned dest, int dstart, int dend) {
        String speChat = "[@#_]";
        Pattern pattern = Pattern.compile(speChat);
        Matcher matcher = pattern.matcher(source.toString());
        if (matcher.find() || source.equals(" ")) return "";
        else return null;
    }
}
